<template>
  <div class="app-container">
    <div class="appLeft">
      <el-input placeholder="请输入内容" v-model="dirName" size="small" style="width: 100px" class="appleftInfut">
        <el-button slot="append" icon="el-icon-search" @click="getDirTreeInfo(dirName)"></el-button>
      </el-input>
      <el-button type="primary" icon="el-icon-plus" class="appLeftBtn" @click="addAttachment">
      </el-button>
      <el-tree :data="treeListData" show-checkbox node-key="id" default-expand-all :expand-on-click-node="false"
        :render-content="renderContent" @node-click="handleNodeClick">
      </el-tree>
    </div>
    <div class="appRight">
      <div class="appRightTop">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="100px">
          <el-form-item label="标准编号">
            <el-input v-model="queryParams.standardId" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="标准中文名">
            <el-input v-model="queryParams.standardChName" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="标准英文名">
            <el-input v-model="queryParams.standardName" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item>
            <el-button type="text" @click="handleQuery" class="gotoseach">搜索</el-button>
            <span type="text" @click="resetQuery" style=" color: #7483a6;
                font-size: 16px;
                font-weight: 500;
                cursor: pointer;
                marginleft: 20px;
              ">重置</span>
          </el-form-item>
        </el-form>
      </div>
      <div class="appRightBtn" v-if="queryParams.catalogueId">
        <el-button :type="item.type" v-for="item in chooseBtnList" :key="item.title" @click="gotoClick(item.title)">{{
        item.title }}</el-button>
      </div>
      <div class="appRightCont">
        <div style="padding-bottom: 22px">
          <div style="float: right" >
            <i class="el-icon-setting iconstyle" @click="setTableColumn()"></i>
          </div>
        </div>
        <el-table :data="tableData" border show-header @selection-change="handleSelectionChange" max-height="380"
          row-key="index" class="ant-table-body tbody" @cell-dblclick="celldblclick">
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column v-for="(item, index) in currentColumn" :prop="item.prop" :label="item.label" :key="index"
            align="center" show-overflow-tooltip>
            <!-- @change="handleCheck(scope.row, scope.row.index)" -->
            <!-- 标准集id -->
            <template slot-scope="scope">
              <span v-if="item.prop === 'catalogueId'">
                <span>{{ scope.row.catalogueId }}</span>
              </span>
              <!-- 标准名 -->
              <span v-else-if="item.prop === 'standardName'">
                <span>{{ scope.row.standardName }}</span>
              </span>
              <!-- 标准中文名 -->
              <span v-else-if="item.prop === 'standardChName'">
                <span>{{ scope.row.standardChName }}</span>
              </span>
              <!-- 字段类型 -->
              <span v-else-if="item.prop === 'standardType'">
                <span>{{ scope.row.standardType }}</span>
              </span>
              <!-- 业务含义 -->
              <span v-else-if="item.prop === 'comment'">
                <span>{{ scope.row.comment }}</span>
              </span>
              <!-- 参考文件id -->
              <span v-else-if="item.prop === 'fileId'">
                <span>{{ scope.row.fileId }}</span>
              </span>
              <!-- 数据长度 -->
              <span v-else-if="item.prop === 'fieldLength'">
                <span>{{ scope.row.fieldLength }}</span>
              </span>
              <!-- 创建人 -->
              <span v-else-if="item.prop === 'createdBy'">
                <span>{{ scope.row.createdBy }}</span>
              </span>
              <!-- 创建时间 -->
              <span v-else-if="item.prop === 'createdTime'">
                <span>{{ scope.row.createdTime }}</span>
              </span>
              <!-- 更新人 -->
              <span v-else-if="item.prop === 'modifiedBy'">
                <span>{{ scope.row.modifiedBy }}</span>
              </span>
              <!-- 更新时间 -->
              <span v-else-if="item.prop === 'modifiedTime'">
                <span>{{ scope.row.modifiedTime }}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column align="center" fixed="right" label="操作">
            <template slot-scope="scope">
              <i class="el-icon-view iconstyle" @click="examine(scope.row)"></i>
              <i class="el-icon-edit-outline iconstyle" @click="editRow(scope.row)"></i>
              <i class="el-icon-delete iconstyle" @click="remove(scope.row)"></i>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!-- 第一层弹框 -->
    <el-dialog title="新建" :visible.sync="dialogVisibleOne" width="30%" :before-close="handleClose">
      <ul class="dialogUl">
        <li v-for="(item, index) in chooseList" :key="index" @click="addchooseTWO(index)">
          {{ item }}
        </li>
      </ul>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleOne = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisibleOne = false">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 第二层弹框 -->
    <el-dialog :title="
      standardAggregateCatalogue.isAggregate == 0
        ? '新建标文件夹'
        : '新建标准集'
    " :visible.sync="dialogVisibleTwo" width="30%" :before-close="handleClose">
      <el-form ref="folderForm" :model="folderForm" label-width="100px"
        v-if="standardAggregateCatalogue.isAggregate === 0">
        <el-form-item label="文件夹名称" prop="name" :rules="{
          required: true,
          message: '请输入文件夹名称',
          trigger: 'blur',
        }">
          <el-input v-model="folderForm.name"></el-input>
          <span>中文、字母、数字、下划线，不允许其他特殊字符，最大长度50字符。</span>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('folderForm', folderForm.name)">提交</el-button>
          <el-button @click="cancelTwo">关闭</el-button>
        </el-form-item>
      </el-form>

      <el-form ref="OtherForm" :model="OtherForm" label-width="100px" v-else>
        <el-form-item label="标准集名称" prop="names" :rules="{
          required: true,
          message: '请输入标准集名称',
          trigger: 'blur',
        }">
          <el-input v-model="OtherForm.names"></el-input>
          <span>中文、字母、数字、下划线，不允许其他特殊字符，最大长度50字符。</span>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('OtherForm', OtherForm.names)">提交</el-button>
          <el-button @click="cancelTwo">关闭</el-button>
        </el-form-item>
      </el-form>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button @click="cancelTwo">取 消</el-button>
        <el-button type="primary" @click="submitForm(folderForm,OtherForm)"
          >确 定</el-button
        >
      </span> -->
    </el-dialog>
    <!-- 修改的弹框 -->
    <el-dialog :title="
      standardAggregateCatalogue.isAggregate == 0
        ? '修改文件夹'
        : '修改标准集'
    " :visible.sync="dialogVisibleChange" width="30%" :before-close="handleCloseChange">
      <el-form ref="standardAggregateCatalogue" :model="standardAggregateCatalogue" label-width="100px">
        <el-form-item :label="
          standardAggregateCatalogue.isAggregate == 0
            ? '修改文件夹名称'
            : '修改标准集名称'
        " prop="catalogueName" :rules="{
            required: true,
            message: '请输入文件夹名称',
            trigger: 'blur',
          }">
          <el-input v-model="standardAggregateCatalogue.catalogueName"></el-input>
          <span>中文、字母、数字、下划线，不允许其他特殊字符，最大长度50字符。</span>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitChange">更改</el-button>
          <el-button @click="dialogVisibleChange = false">关闭</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 导入的弹框 -->
    <el-dialog :title="
      standardAggregateCatalogue.isAggregate == 0 ? '导入标准' : '导入标准集'
    " :visible.sync="dialogVisibleImport" width="30%" :before-close="handleClose">
      <el-button @click="OnlockUpdown">点击此处下载模板</el-button>
      <el-form ref="OtherForm" :model="OtherForm" label-width="100px">
        <el-form-item label="标准集名称" prop="names" :rules="{
          required: true,
          message: '请输入标准集名称',
          trigger: 'blur',
        }" v-if="standardAggregateCatalogue.isAggregate != 0">
          <el-input v-model="OtherForm.names"></el-input>
          <span>中文、字母、数字、下划线，不允许其他特殊字符，最大长度50字符。</span>
        </el-form-item>
        <el-form-item label="上传文件">
          <el-upload class="upload-demo" ref="upload" :action="action" accept=".xlsx,.xls" :headers="headers"
            :on-change="handlePreview" :on-success="handleFileSuccess" :file-list="fileList" :auto-upload="false"
            :data="queryImport">
            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
            <div slot="tip" class="el-upload__tip">
              请上传.xls、.xlsx格式的文件
            </div>
          </el-upload>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitImport">提交</el-button>
          <el-button @click="ImportClose">关闭</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 导入多个 -->
    <el-dialog title="导入多个" :visible.sync="dialogVisibleImportAll" width="30%" :before-close="handleClose">
      <el-form ref="OtherForm" :model="OtherForm" label-width="100px">
        <el-form-item label="上传文件">
          <el-upload class="upload-demo" ref="upload" action="#" accept=".xlsx,.xls" :headers="headers"
            :on-change="handlePreviewAll" :file-list="fileListAll" :auto-upload="false">
            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
            <div slot="tip" class="el-upload__tip">
              请上传.xls、.xlsx格式的文件
            </div>
          </el-upload>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitImportAll">提交</el-button>
          <el-button @click="ImportCloseAll">关闭</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <AddstandarTable :allHeaderList="allHeaderList" v-if="dynamicTableDialog" :detailflag="dynamicTableDialog"
      :checkedColumnList="checkedColumnList" @closeDynamicTable="closeDynamicTable">
    </AddstandarTable>
    <newStandard ref="newStandardInfo" :dialogflag="dialogVisible" :catalogueId="queryParams.catalogueId"
      v-if="dialogVisible" @closedia="closedia" :dataObj="dataObj" :chooseDataList="chooseDataList"
      :tableData="tableData">
    </newStandard>
  </div>
</template>

<script>
import AddstandarTable from "./componnets/AddstandarTable.vue";
import newStandard from "./componnets/newStandard.vue";

import {
  getDirTree,
  createDir,
  getAllTableConfig,
  getTableConfig,
  queryStandard,
  updateDir,
  importCatalogue,
  createStandard,
  updateStandard,
  removeStandard,
  exportStandard,
  importCatalogueAll
} from "@/api/dataStandard/standardManagement.js";
export default {
  name: "standardManagement",
  components: {
    AddstandarTable,
    newStandard,
  },
  data() {
    return {
      //左侧查询的内容
      dirName: "",
      //上传的网址
      action: "",
      //设置请求头
      headers: { "Content-Type": "multipart/form-data;charset=UTF-8" },
      //第一层loding是否显示
      dialogVisibleOne: false,
      //第二层loding是否显示
      dialogVisibleTwo: false,
      //新建标准的显示隐藏
      dialogVisible: false,
      dynamicTableDialog: false,
      //修改的弹框是否显示
      dialogVisibleChange: false,
      //导入的时候的弹框是否显示
      dialogVisibleImport: false,
      //导出多个
      dialogVisibleImportAll: false,
      //新建文件夹的显示隐藏----默认显示
      folderShow: true,
      //选择的哪一个  0---文件夹  1----标准集
      // chooseVal: 0,
      //表格全部行数据
      tableData: [],
      //当前表格列
      currentColumn: [],
      //当前左侧树的数据
      treeListData: [],
      //传给子页面的表格数据
      checkedColumnList: [],
      //新建文件夹参考标准文件回来的数据
      chooseDataList: [],
      //上传的文件列表
      fileList: [],
      //上传的文件列表
      fileListAll: [],
      //删除的listID
      standardIdsLidt: [],
      //导出的list
      oepnlistAllList: [],
      //传入的数据
      queryImport: {},
      //新建文件标准的数据
      dataObj: {},
      //文件夹的form
      folderForm: {
        name: "",
      },
      OtherForm: {
        names: "",
        parentDirId: "",
      },
      //搜索条件
      queryParams: {
        catalogueId: "", // 标准集id
        standardId: "", //标准编号
        standardChName: "", //标准中文名
        standardName: "", //标准英文名
        page: -1,
        size: -1,
      },
      //新建文件夹/标准集的条件
      standardAggregateCatalogue: {
        catalogueName: "", //标准集名称
        isAggregate: 0, //是否为标准集 0否1是
        pid: "0", //父级id
      },
      //循环的一层loding
      chooseList: ["新建文件夹", "新建标准集"],
      //按钮的list
      chooseBtnList: [
        { type: "primary", title: "新建标准" },
        { type: "", title: "批量删除" },
        { type: "", title: "导入" },
        { type: "", title: "导出" },
      ],
    };
  },
  watch: {
    //  'queryParams.current'(newNum,oldNum){
    //          console.log(newNum,oldNum);
    //  },
    deep: true, //true 深度监听
  },
  mounted() {
    let baseUrl = sessionStorage.getItem("baseUrl");
    this.action = baseUrl + "/standardAggregateCatalogue/importCatalogue";
    //一进来先去请求左侧tree
    this.getDirTreeInfo();
    //获取表头配置
    this.getAllTableConfigInfo();
  },
  methods: {
    //新建标准
    addAttachment() {
      this.dialogVisibleOne = true;
    },
    //是否关闭第一层
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => { });
    },
    //选择是否是新建文件夹、还是新建标准集
    addchooseTWO(val) {
      this.standardAggregateCatalogue.isAggregate = val;
      this.dialogVisibleOne = false;
      this.dialogVisibleTwo = true;
    },
    //第二层的取消返回第一层loding
    cancelTwo() {
      this.dialogVisibleOne = true;
      this.dialogVisibleTwo = false;
      if (this.standardAggregateCatalogue.isAggregate == 0) {
        this.$refs.folderForm.clearValidate();
      } else {
        this.$refs.OtherForm.clearValidate();
      }
    },
    //第二层的提交
    submitForm(form, val) {
      console.log(form, val, this.$refs[form], "this.$refs[form]");
      this.$refs[form].validate((valid) => {
        if (valid) {
          this.dialogVisibleTwo = false;
          this.standardAggregateCatalogue.catalogueName = val;
          createDir(this.standardAggregateCatalogue)
            .then((response) => {
              if (response.success) {
                this.$modal.msgSuccess("新建成功");
                //然后重新获取左侧的树
                this.getDirTreeInfo();
              }
            })
            .catch((err) => {
              // this.$message.error(err.message);
              console.log(err);
            });
          this.$refs[form].resetFields();
        }
      });
    },
    //点击搜索，进行模糊查询
    handleQuery() {
      if (this.queryParams.standardId == "") {
        delete this.queryParams.standardId;
      }
      if (this.queryParams.standardChName == "") {
        delete this.queryParams.standardChName;
      }
      if (this.queryParams.standardName == "") {
        delete this.queryParams.standardName;
      }
      queryStandard(this.queryParams)
        .then((res) => {
          if (res.success) {
            this.$modal.msgSuccess("查询成功！");
            this.tableData = res.data;
          }
        })
        .catch((err) => {
          // this.$message.error(err.message);
          console.log(err);
        });
    },
    //点击重置
    resetQuery() {
      this.queryParams.standardId = "";
      this.queryParams.standardChName = "";
      this.queryParams.standardName = "";
      this.queryParams.current = 1;
      this.$modal.msgSuccess("重置成功！");
    },
    //勾选change
    handleSelectionChange(val) {
      console.log(val, '选中的值');
      this.multipleSelection = val;
    },
    //实现双击复制时间
    celldblclick(row, column, cell, event) {
      if (event.type === "dblclick") {
        var rowType = column.property;
        var save = function (e) {
          e.clipboardData.setData("text/plain", row[rowType]);
          e.preventDefault(); //阻止默认行为
        };
        // 添加copy事件
        document.addEventListener("copy", save);
        //复制选中的文字到剪贴板;
        document.execCommand("copy");
        //移除addEventListener的事件
        document.removeEventListener("copy", save);
      }
      //复制成功后提示
      this.$message({
        message: "复制 " + row[rowType] + " 成功",
        type: "success",
      });
    },
    //按钮集合点击的时候
    gotoClick(key) {
      switch (key) {
        case "新建标准":
          return this.addStandar();
        case "批量删除":
          return this.removeAll();
        case "导入":
          return this.uploadAll();
        case "导出":
          return this.oepnlistAll();
        default:
          break;
      }
    },
    //新建标准
    addStandar() {
      this.dialogVisible = true;
    },
    //批量删除
    removeAll() {
      this.multipleSelection.map((item) => {
        this.standardIdsLidt.push(item.id)
      })
      this.standardIdsLidt = [...new Set(this.standardIdsLidt)]
      this.removeStandardFun(this.standardIdsLidt)
    },
    //导入
    uploadAll() {
      this.dialogVisibleImportAll = true;
    },
    //导出多个
    oepnlistAll() {
      let baseUrl = window.sessionStorage.getItem("baseUrl");
      this.multipleSelection.map((item) => {
        this.oepnlistAllList.push(item.id)
      })
      this.oepnlistAllList = [...new Set(this.oepnlistAllList)]
      console.log(this.oepnlistAllList, 'this.oepnlistAllList');
      exportStandard(this.oepnlistAllList).then((res) => {
        console.log(res, '...........');
        this.downloadFile(res, `user_template_${new Date().getTime()}.xlsx`)
      }).catch((err) => {
        // this.$message.error(err.message);
        console.log(err);
      });
      //  this.download('/standardAggregate/exportStandard', this.oepnlistAllList, `user_template_${new Date().getTime()}.xlsx`)
    },
    //获取左侧Tree
    getDirTreeInfo(val) {
      let queryDirTreeInfo = {
        dirName: val,
      };
      getDirTree(queryDirTreeInfo)
        .then((response) => {
          console.log(response, "111111111");
          this.treeListData = JSON.parse(JSON.stringify(response.data));
          //再去获取动态表头 然后对比
          this.getTableTou();
        })
        .catch((err) => {
          // this.$message.error(err.message);
          console.log(err);
        });
    },
    //获取表头配置
    getAllTableConfigInfo() {
      getAllTableConfig()
        .then((response) => {
          console.log(response, "00000000000000");
          this.allHeaderList = response.data;
        })
        .catch((err) => {
          // this.$message.error(err.message);
          console.log(err);
        });
    },
    //获取动态表头
    getTableTou() {
      //不是新建
      getTableConfig()
        .then((response) => {
          if (response.data) {
            let headerList = response.data.headerList;
            //   //编辑 -获取的列头数据
            this.currentColumn = [];
            headerList.forEach((item) => {
              this.allHeaderList.forEach((i) => {
                if (item == i.prop) {
                  this.currentColumn.push(i);
                  this.checkedColumnList.push(i.label);
                }
              });
            });
            this.checkedColumnList = [...new Set(this.checkedColumnList)];
          }
        })
        .catch((err) => {
          // this.$message.error(err.message);
          console.log(err);
        });
    },
    //关闭配置表头弹框
    closeDynamicTable(arr) {
      this.dynamicTableDialog = false;
      if (arr) {
        this.currentColumn = arr;
      }
    },
    //删除
    remove(row) {
      console.log(row, "删除");
      this.standardIdsLidt.push(row.id);
      this.standardIdsLidt = [...new Set(this.standardIdsLidt)]
      this.removeStandardFun(this.standardIdsLidt)
    },
    //删除的封装
    removeStandardFun(val) {
      removeStandard(val)
        .then((res) => {
          if (res.success) {
            this.$modal.msgSuccess("新建成功");
            //成功了以后就掉重新查询的接口
            this.handleQuery();
          }
        })
        .catch((err) => {
          // this.$message.error(err.message);
          console.log(err);
        });
    },
    //查看
    examine(row) {
      this.dataObj = { flag: "examine", row, condition: 0 };
      this.dialogVisible = true;
    },
    //编辑
    editRow(row) {
      this.dataObj = { flag: "edit", row, condition: 1 };
      this.dialogVisible = true;
    },
    //左侧树的添加
    renderContent(h, { node, data, store }) {
      if (node.level == 1) {
        return (
          <span class="custom-tree-node">
            <span style="marginRight:10px">{node.label}</span>
            <span>
              <el-button
                icon="el-icon-circle-plus-outline"
                size="mini"
                circle
                on-click={() => this.treeappend(data)}
              ></el-button>
              <el-button
                icon="el-icon-remove-outline"
                size="mini"
                circle
                on-click={() => this.treeremove(data)}
              ></el-button>
              <el-button
                icon="el-icon-edit"
                size="mini"
                circle
                on-click={() => this.treechanged(data)}
              ></el-button>
              <el-button
                icon="el-icon-download"
                size="mini"
                circle
                on-click={() => this.treedownload(data)}
              ></el-button>
              <el-button
                icon="el-icon-upload2"
                size="mini"
                circle
                on-click={() => this.tressupload(data)}
              ></el-button>
            </span>
          </span>
        );
      } else {
        return (
          <span class="custom-tree-node">
            <span style="marginRight:10px">{node.label}</span>
            <span>
              <el-button
                icon="el-icon-edit"
                size="mini"
                circle
                on-click={() => this.treechanged(data)}
              ></el-button>
              <el-button
                icon="el-icon-download"
                size="mini"
                circle
                on-click={() => this.treedownload(data)}
              ></el-button>
              <el-button
                icon="el-icon-upload2"
                size="mini"
                circle
                on-click={() => this.tressupload(data)}
              ></el-button>
            </span>
          </span>
        );
      }
    },
    //添加左侧树
    treeappend(data) {
      event.cancelBubble = true;
      this.dialogVisibleOne = true;
      this.standardAggregateCatalogue.pid = data.pid;
    },
    //修改左侧树
    treechanged(data) {
      event.cancelBubble = true;
      this.dialogVisibleChange = true;
      this.standardAggregateCatalogue.catalogueName = data.label;
      this.standardAggregateCatalogue.isAggregate = data.isAggregate;
      this.standardAggregateCatalogue.pid = data.pid;
      this.standardAggregateCatalogue.id = data.id;
    },
    //导出
    oepnlist(val) {
      let baseUrl = window.sessionStorage.getItem("baseUrl");
      let queryDownloadInfo =
        baseUrl + "/standardAggregateCatalogue/exportCatalogue?dirId=" + val;
      //  window.open('http://192.168.1.90:48082/standardAggregateCatalogue/exportCatalogue?dirId=089069c780b9451d8f9efdf4a3fe4b97', "_blank");
      // console.log(baseUrl);
      window.open(queryDownloadInfo, "_blank");
    },
    //下载
    treedownload(data) {
      event.cancelBubble = true;
      this.oepnlist(data.id);
    },
    //上传
    tressupload(data) {
      event.cancelBubble = true;
      this.dialogVisibleImport = true;
      this.standardAggregateCatalogue.isAggregate = data.isAggregate;
      this.OtherForm.parentDirId = data.pid;
      // let baseUrl = window.sessionStorage.getItem("baseUrl");
      // this.action=baseUrl+'/standardAggregateCatalogue/exportCatalogue';
    },
    //配置表头
    setTableColumn() {
      this.currentColumn.forEach((item) => {
        this.allHeaderList.forEach((i) => {
          if (item.prop == i.prop) {
            this.currentColumn.push(i);
            this.checkedColumnList.push(i.label);
          }
        });
      });
      this.dynamicTableDialog = true;
    },
    //新建标准穿回来的数据
    closedia(title, diaData, condition) {
      console.log(title, diaData, condition, "新建标准穿回来的数据");
      this.dialogVisible = false;
      if (title == "新建标准") {
        createStandard(diaData)
          .then((res) => {
            console.log(res, "88888888888");
            if (res.success) {
              this.$modal.msgSuccess("新建成功");
              //成功了以后就掉重新查询的接口
              this.handleQuery();
            }
          })
          .catch((err) => {
            console.log(err);
            // this.$message.error(err.message);
          });
      } else if (title == "编辑") {
        updateStandard(diaData)
          .then((res) => {
            console.log(res, "88888888888");
            if (res.success) {
              this.$modal.msgSuccess("修改成功");
              //成功了以后就掉重新查询的接口
              this.handleQuery();
            }
          })
          .catch((err) => {
            console.log(err);
            // this.$message.error(err.message);
          });
      } else {
        return;
      }
    },
    //树的节点被点击的时候
    handleNodeClick(data) {
      console.log(data, "被点击le");
      this.queryParams.catalogueId = data.id;
      this.handleQuery();
    },
    //是否要关闭更改标准集
    handleCloseChange(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => { });
    },
    //更改标准集
    submitChange() {
      this.dialogVisibleChange = false;
      updateDir(this.standardAggregateCatalogue)
        .then((response) => {
          if (response.success) {
            this.$modal.msgSuccess("修改成功");
            //重新获取左侧树
            this.getDirTreeInfo();
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //导入多个
    submitImportAll() {
      console.log(this.fileListAll);
      if (this.fileListAll.length === 0) {
        this.$message.error("请选择文件");
        return;
      }
      if (this.fileListAll.length > 1) {
        this.$message.error("最多选择一个文件");
        return;
      }
      let formData = new FormData();
      formData.append("multipartFile", this.fileListAll[0].raw);
      formData.append("catalogueId", this.queryParams.catalogueId);
      importCatalogueAll(formData)
        .then((response) => {
          console.log(response);
          if (response.success) {
            this.$message.success("上传成功");
            this.dialogVisibleImportAll = false;
            this.this.fileListAll = [];
            //获取左侧树
            this.getDirTreeInfo();
          }
        })
        .catch((err) => {
          // this.$message.error(err.message);
          console.log(err);
        });
    },
    //导入
    submitImport() {
      if (this.fileList.length === 0) {
        this.$message.error("请选择文件");
        return;
      }
      if (this.fileList.length > 1) {
        this.$message.error("最多选择一个文件");
        return;
      }
      let formData = new FormData();
      formData.append("multipartFile", this.fileList[0].raw);
      formData.append("catalogueName", this.OtherForm.names);
      formData.append("parentDirId", this.OtherForm.parentDirId);
      importCatalogue(formData)
        .then((response) => {
          console.log(response);
          if (response.success) {
            this.$message.success("上传成功");
            this.dialogVisibleImport = false;
            this.this.fileList = [];
            //获取左侧树
            this.getDirTreeInfo();
          }
        })
        .catch((err) => {
          // this.$message.error(err.message);
          console.log(err);
        });
    },
    //关闭导入
    ImportClose() {
      this.dialogVisibleImport = false;
      this.fileList = [];
      this.$refs.OtherForm.clearValidate();
    },
    //关闭导入
    ImportCloseAll() {
      this.dialogVisibleImportAll = false;
      this.fileListAll = [];
    },
    //文件状态改变
    handlePreview(file, fileList) {
      this.fileList = fileList;
    },
    //文件状态改变---多选
    handlePreviewAll(file, fileList) {
      this.fileListAll = fileList;
    },
    //上传成功
    handleFileSuccess(response, file, fileList) {
      this.fileList = fileList;
      if (response.success) {
        this.$message.success("上传成功");
        this.$parent.getList();
      } else {
        this.$message.error(response.message);
      }
    },
    //移除成功
    onRemoveDr(file, fileList) {
      this.fileList = fileList;
    },
    //导出模板
    OnlockUpdown() {
      let baseUrl = window.sessionStorage.getItem("baseUrl");
      let queryDownloadInfo =
        baseUrl + "/standardAggregate/exportStandardTemplate";
      window.open(queryDownloadInfo, "_blank");
    },
  },
};
</script>
<style lang="scss" scoped>
@import "~@/assets/styles/mixin.scss";
@import "~@/assets/styles/variables.scss";

.app-container {
  font-family: "PingFang SC", "microsoft yahei";
  background: #fff;
  height: 755px;
}

.appLeft {
  float: left;
  width: 300px;
  height: 100%;
  padding: 20px;
  border-right: 1px solid #ccc;
}

.appleftInfut {
  width: 200px !important;
}

.appLeftBtn {
  width: 35px;
  height: 30px;
  padding: 0 5px;
  margin-left: 10px;
}

.el-tree {
  margin-top: 30px;
}

::v-deep .el-tree .el-button--mini.is-circle {
  padding: 0px;
}

::v-deep .el-tree .el-button.is-circle {
  border: none;
}

.dialogUl {
  height: 200px;
  list-style: none;
  text-align: center;

  li {
    width: 200px;
    height: 200px;
    float: left;
    border: 1px dashed #ccc;
    margin-left: 15px;
  }
}

.appRight {
  float: left;
  width: calc(100% - 300px);
  height: 100%;
}

.appRightTop {
  padding: 20px;

  .gotoseach {
    font-size: 15px;
  }
}

.appRightBtn {
  padding: 0 50px;
}

.appRightCont {
  padding: 50px 150px 0 50px;
}
</style>
